package com.hushan.elevator.dto;

import com.hushan.elevator.model.RiskRecord;
import jakarta.persistence.Column;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RiskRecordDto {
    private Integer recordId;
    private String deviceSerial;
    private String serialNumber;
    private int isStar;
    private String eventId;
    private Integer state;
    private LocalDateTime createdTime;
    private LocalDateTime finishedTime;
    private String riskPic;
    int riskLevel;
    String riskTitle;
    int riskType;
    int deviceId;
    String deviceName;
    int deviceManager; // device creator
    String deptName;
    String deptAddress;
    int deptParentId;
    String deptAncestors;
    int deptId;


    public RiskRecordDto(Object[] result) {
        this.recordId = (Integer) result[0];
        this.deviceSerial = (String) result[1];
        this.isStar = (Boolean) result[2]? 1 : 0;
        this.eventId = (String)result[3];
        this.serialNumber = (String) result[4];
        this.state = (Boolean) result[5] ? 1 : 0;
        this.createdTime = ((Timestamp) result[6]).toLocalDateTime();
        this.finishedTime = result[7]==null?null:((Timestamp) result[7]).toLocalDateTime();
        this.riskLevel = (int)((Byte) result[8]) ;
        this.riskTitle = (String) result[9];
        this.riskType = (int)((Byte) result[10]);
        this.deviceId = (int) result[11];
        this.deviceName = (String) result[12];
        this.deviceManager = (int) result[13];
        this.deptName = (String) result[14];
        this.deptAddress = (String) result[15];
        this.deptParentId = (int) result[16];
        this.deptAncestors = (String) result[17];
        this.deptId = (Integer) result[18];
        this.riskPic = (String) result[19];
    }
}
